<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0px;padding: 0px;
        }
        div{
            color: red;font-size: 30px;text-align: center;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script type="text/javascript">
        var box = document.getElementById("box");
        var endTime = new Date("2020/01/10 17:30:00");//结束的时间
        var timer = setInterval(function () {
            var date = new Date();
            var ms = endTime.getTime() - date.getTime()  ;//获得毫秒数目
            var second = parseInt(ms/1000);
            var mins = parseInt(second/60);
            var hour = parseInt(second/3600%24);
            var days = parseInt(second/3600/24);

            days<10 ? days="0"+days : days;
            hour<10 ? hour="0"+hour : hour;
            mins<10 ? mins="0"+mins : mins;
            second<10 ? second="0"+second : second;
            box.innerHTML = "距离回家时间还剩: "+days+"天 "+hour+"小时 "+mins+"分钟 "+second+"秒";

        },1000)


    </script>

</body>
</html>